import http from '@/utils/request'

const apiBefore = 'web/pay'

export const pay = {
  paywall: params => {
    return http.get(`${apiBefore}/sys/paywall/plan/app`, {
      params
    })
  },
  rules: params => {
    return http.get(`${apiBefore}/sys/paywall/plan/rules`, {
      params
    })
  },
  pay: (params) => {
    return http.post(`${apiBefore}/sys/paywall/pay`, params)
  },
  getPaymentList: () => {
    return http.get(`${apiBefore}/tenant/paywall/paymentList`)
  },
  saveRule: (params) => {
    return http.post(`${apiBefore}/sys/paywall/save`, params)
  },
  selectDashboardByAppId: (id) => {
    return http.get(`${apiBefore}/sys/paywall/selectDashboardByAppId?id=${id}`)
  },
  retrieve: (params) => {
    return http.get(`${apiBefore}/sys/paywall/retrieve`, {
      params
    })
  },
  botAmount: (params) => {
    return http.get(`${apiBefore}/sys/paywall/botAmount`, {
      params
    })
  },
  productFamilies: (params) => {
    return http.get(`${apiBefore}/sys/chargbeeItemPrices/listProduct`, {
      params
    })
  },
  products: (params) => {
    return http.get(`${apiBefore}/sys/chargbeeItemPrices/listPlans`, {
      params
    })
  },
  payCallback: (params) => {
    return http.put(`${apiBefore}/tenant/paywall/update`, params)
  },
  renewal: (params) => {
    return http.put(`${apiBefore}/tenant/free/time/update`, params)
  },
  sub: (params) => {
    return http.post(`${apiBefore}/tenant/paywall/save`, params)
  },
  appUserRight: (params) => {
    return http.get(`${apiBefore}/sys/paywall/appUserRight`, { params })
  },
  freeUser: (params) => {
    return http.get(`${apiBefore}/sys/paywall/freeUser`, { params })
  },
  payInfo: (params) => {
    return http.get(`${apiBefore}/sys/paywall/info`, { params })
  },
  checkoutExistingForItems: (params) => {
    return http.post(`${apiBefore}/sys/paywall/checkoutExistingForItems`, params)
  },
  updateSubscription: (params) => {
    return http.post(`${apiBefore}/sys/paywall/updateSubscription`, params)
  },
  paywallDelete: (params) => {
    return http.delete(`${apiBefore}/tenant/paywall/delete`, { params })
  },

  sharePicture: (params) => {
    return http.get(`${apiBefore}/sys/paywall/sharePicture`, { params })
  },
  integrationResource: (params) => {
    return http.get(`${apiBefore}/sys/paywall/integrationResource`, { params })
  },
  subList: (params) => {
    return http.get(`${apiBefore}/sys/paywall/subscriptionList-show`, { params })
  },
  billingHistoryList: (params) => {
    return http.get(`${apiBefore}/sys/paywall/transactionList`, { params })
  },
  invoiceDownload: (params) => {
    return http.get(`${apiBefore}/sys/paywall/invoiceDownload`, { params })
  },
  paymentSourceList: (params) => {
    return http.get(`${apiBefore}/sys/paywall/getCustomer`, { params })
  },
  createPaymentSource: (params) => {
    return http.post(`${apiBefore}/sys/paywall/createPaymentSources`, params)
  },
  editPaymentSource: (params) => {
    return http.post(`${apiBefore}/sys/paywall/updatePaymentSources`, params)
  },
  deletePaymentSource: (id) => {
    return http.delete(`${apiBefore}/sys/paywall/removePaymentSources/${id}`)
  },
  createBankAccount: (params) => {
    return http.post(`${apiBefore}/sys/paywall/createBankAccount`, params)
  },
  verifyBankAccount: (params) => {
    return http.post(`${apiBefore}/sys/paywall/verifyBankAccount`, params)
  },
  assignPaymentRole: (params) => {
    return http.post(`${apiBefore}/sys/paywall/assignPaymentRole`, params)
  },
  paymentList: (params) => {
    return http.get(`${apiBefore}/sys/paywall/paymentSourceList`, params)
  },
  customerAndMapping: (params) => {
    return http.post(`${apiBefore}/sys/chargbeeItemPrices/customerAndMapping`, params)
  },
  getCustomerAndCard: (params) => {
    return http.get(`${apiBefore}/sys/paywall/getChargebeeCustomer`, { params })
  },
  cancelSubscription: (params) => {
    return http.get(`${apiBefore}/sys/paywall/cancelForItems`, { params })
  },
  activationSubscription: (params) => {
    return http.post(`${apiBefore}/sys/paywall/reactivateSubscription`, params)
  },
  nextBillingAmount: (params) => {
    return http.get(`${apiBefore}/sys/paywall/nextBillingAmount?tenantCode=${params.tenantCode}`, params)
  },
  getSubId: (params) => {
    return http.get(`${apiBefore}/tenant/paywall/info`, { params })
  },
  getPaidProduct: () => {
    return http.get(`${apiBefore}/tenant/paywall/status`, {}, { cache: { enable: true } })
  },
  cancelSub: (params) => {
    return http.get(`${apiBefore}/sys/paywall/cancelForItems`, { params })
  },
  closeBot: ({ botId }) => {
    return http.put(`${apiBefore}/sys/paywall/closeBot?botId=${botId}`)
  },

  saveBiPackage: (params) => {
    return http.post(`${apiBefore}/sys/bundle/save`, params)
  },
  getBiPackageList: (params) => {
    return http.get(`${apiBefore}/sys/bundle/list`, { params })
  },
  editPaywall: (params) => {
    return http.post(`${apiBefore}/tenant/paywall/ConfigureTenantsToPaywall`, params)
  },
  createItemByItemPrice: (params) => {
    return http.post(`${apiBefore}/tenant/paywall/createItemByItemPrice`, params)
  },
  getBrightGauge: (params) => {
    return http.get(`${apiBefore}/tenant/paywall/thirdPartyId`, { params })
  },
  newSave: (params) => {
    return http.post(`${apiBefore}/sys/paywall/newSave`, params)
  },
  getBotTotal: (params) => {
    return http.get(`${apiBefore}/sys/paywall/getBotTotal`, { params })
  },
  saveOnBoarding: (params) => {
    return http.post(`${apiBefore}/sys/tenant/onboarding`, params)
  },
  updateOnBoarding: (params) => {
    return http.put(`${apiBefore}/sys/tenant/onboarding/${params.id}/update`, params)
  },
  getBotUserList: (params) => {
    return http.get(`${apiBefore}/sys/bot/assign/info`, { params })
  },
  saveBotUserList: (params) => {
    return http.post(`${apiBefore}/sys/bot/assign/save`, params )
  },
  saveAlaCarteUser: (params) => {
    return http.post(`${apiBefore}/tenant/paywall/staffExpansion`, params)
  },
  getPaywallInfo: (params) => {
    return http.get(`${apiBefore}/tenant/paywall/getCreateSubscription`, { params })
  },
  getPaywallCountUser: (params) => {
    return http.get(`${apiBefore}/tenant/paywall/getTenantCodeUsers`, { params })
  },
  saveShareInfoApi: (params) => {
    return http.post(`${apiBefore}/sys/share/register`, params)
  },
  checkPrice: (params) => {
    return http.post(`${apiBefore}/sys/chargbeeItemPrices/checkPrice`, params)
  },
  updateCheckPrice: (params) => {
    return http.post(`${apiBefore}/sys/chargbeeItemPrices/updateSubscriptionForItems`, params)
  },
  paywallTenantList: params => {
    return http.get(`${apiBefore}/sys/paywall/setting/tenantList`, { params }, { cache: { enable: false } })
  },
  getClientRequestList: params => {
    return http.get(`${apiBefore}/sys/tenant/setting/getTenantByApproval`, { params }, { cache: { enable: false } })
  },
  getClientRequestDetail: params => {
    return http.get(`${apiBefore}/sys/tenant/setting/getApplicationRecord`, { params }, { cache: { enable: false } })
  },
  changeClientRequestStatus: (params) => {
    return http.post(`${apiBefore}/sys/tenant/setting/save`, params)
  },
  getExpirationTime: (params) => {
    return http.get(`${apiBefore}/sys/tenant/setting/getExpirationTime`, { params })
  },
  getAutoApprove: (params) => {
    return http.get(`${apiBefore}/sys/tenant/setting/getAutoApprove`, { params })
  },
  requestDay: (params) => {
    return http.post(`${apiBefore}/sys/tenant/setting/requestDay?type=${params.type}`,  params)
  },
  getOld: (params) => {
    return http.get(`${apiBefore}/sys/tenant/setting/getOld`, { params })
  },
  cancelTenantSubscription: (params) => {
    return http.delete(`${apiBefore}/sys/paywall/cancelSubscription/${params.id}`, { params })
  },
  queryNumberByUsers: (params) => {
    return http.post(`${apiBefore}/tenant/free/time/queryNumberByUsers`, params)
  },
  updateUserRole: (params) => {
    return http.put(`${apiBefore}/sys/role/user/saveOrUpdate`, params)
  },
  selectSubscription: (params) => {
    return http.get(`${apiBefore}/sys/paywall/selectSubscription`, { params })
  },
  updateFormItems: (params) => {
    return http.put(`${apiBefore}/sys/paywall/updateForItems`, params)
  },
  disableCWUser: (params) => {
    return http.get(`${apiBefore}/sys/role/user/disableCWUser`, { params })
  },
  disableAutoTaskUser: (params) => {
    return http.get(`${apiBefore}/sys/role/user/disableAutoTaskUser`, { params })
  },
  modifyOurPartners: (params, type) => {
    return http.post(`${apiBefore}/sys/paywall/setting/partners/${type}`, params)
  },
  alaCarteUpdate: (params) => {
    return http.put(`${apiBefore}/sys/bot/assign/update`, params)
  },
  chargebeePrice: () => {
    return http.get(`${apiBefore}/tenant/paywall/chargeBeeProductList`)
  },
  getUserNextTicketApp: () => {
    return http.get(`${apiBefore}/sys/role/user/nextTicketApp`)
  },
  chargebeePriceUpdate: (params) => {
    return http.post(`${apiBefore}/tenant/paywall/itemPriceUpdate`, params)
  },
  getPaywallLog: (params) => {
    return http.get(`${apiBefore}/opt/log/page`, { params })
  },
  getPaywallLogTable: (params) => {
    return http.get(`${apiBefore}/opt/log/${params.tenantCode}`)
  },
  payUser: (params) => {
    return http.post(`${apiBefore}/sys/pay/user`, params)
  },
  getPaywallCoupon: () => {
    return http.get(`${apiBefore}/tenant/paywall/couponList`)
  },
  getPaywallCouponCode: (params) => {
    return http.get(`${apiBefore}/tenant/paywall/estimateCouponCode`, { params })
  },
  savePaywallAddress: (params) => {
    return http.post(`${apiBefore}/sys/paywall/updateBillingAddress`, params)
  }
}
